<?php

require('config.php');

$page = new rootLayoutPrint();
$translate = tmxTranslate('place_detail.xml', REP_XLAT_TEMPLATE);
$tpl_file='print_client_file.tpl';
$print_client_file = new flyLayout(REP_TPL . $tpl_file);
$print_client_file->start();
$id_client_mandatory_sale=$_GET['id'];
$language_code = (isset($_POST['language_code'])?$_POST['language_code']:$_SESSION['language_code']);
$clientFile = modelClientFile::getListClientFile($id_client_mandatory_sale);//$status =2,3,6 
$clientFileDistrict = modelClientFile::getListClientFileDistrict($id_client_mandatory_sale);//$status =2,3,6
$getListDistrict= modelClientFile::getListDistrictbyIdMandatory($id_client_mandatory_sale);//$status =2,3,6
//echo $getListDistrict->size();exit();
//echo $clientFileDistrict->size();exit;
foreach($getListDistrict as $key => $district) {
			$print_client_file->setVariable('district',$district->title);	
			$print_client_file->parseList('list_district');
		}
	
	if($clientFile)
	{
		$page->setBaliseTitle($id_client_mandatory_sale);
		if($clientFile->rooftop_name!=''){
				$print_client_file->setVariable('rooftop_name',($clientFile->rooftop_name));
				$print_client_file->showBlock('show_rooftop_name');
			}
		if($clientFile->rooftop_phone!=''){
				$print_client_file->setVariable('rooftop_phone_number',($clientFile->rooftop_phone));
				$print_client_file->showBlock('show_rooftop_phone_number');
			}
		if($clientFile->rooftop_email!='0'){
				$print_client_file->setVariable('rooftop_email',($clientFile->rooftop_email));
				$print_client_file->showBlock('show_rooftop_email');
			}
		if($clientFile->first_name!=''){
				$print_client_file->setVariable('first_name',($clientFile->first_name));
				$print_client_file->showBlock('show_first_name');
			}
		if($clientFile->last_name!=''){
				$print_client_file->setVariable('last_name',($clientFile->last_name));
				$print_client_file->showBlock('show_last_name');
			}
		if($clientFile->sex!=''){
				$print_client_file->setVariable('sex',($clientFile->sex));
				$print_client_file->showBlock('show_sex');
			}
		if($clientFile->address!=''){
				$print_client_file->setVariable('address',($clientFile->address));
				$print_client_file->showBlock('show_address');
			}
		if($clientFile->address_in_phnompenh!=''){
				$print_client_file->setVariable('address_in_phnompenh',($clientFile->address_in_phnompenh));
				$print_client_file->showBlock('show_address_in_phnompenh');
			}
		if($clientFile->nationality!=''){
				$print_client_file->setVariable('nationality',($clientFile->nationality));
				$print_client_file->showBlock('show_nationality');
			}
		if($clientFile->passport_number!=''){
				$print_client_file->setVariable('passport_number',($clientFile->passport_number));
				$print_client_file->showBlock('show_passport_number');
			}
			if($clientFile->type_visa!=''){
				$print_client_file->setVariable('type_visa',($clientFile->type_visa));
				$print_client_file->showBlock('show_type_visa');
			}
			if($clientFile->date_expiration!=0){
				$print_client_file->setVariable('date_expiration',date('Y-m-d',$clientFile->date_expiration));
				$print_client_file->showBlock('show_date_expiration');
			}
		if($clientFile->how_know_rooftop!=''){
				$print_client_file->setVariable('how_know_rooftop',$clientFile->how_know_rooftop);
				$print_client_file->showBlock('show_how_know_rooftop');
			}
		if($clientFile->tel!=''){
				$print_client_file->setVariable('tel',$clientFile->tel);
				$print_client_file->showBlock('show_tel');
			}
		if($clientFile->email!=''){
				$print_client_file->setVariable('email',$clientFile->email);
				$print_client_file->showBlock('show_email');
			}
		if($clientFile->want_to!=''){
				$print_client_file->setVariable('want_to',$clientFile->want_to);
				$print_client_file->showBlock('show_want_to');
			}
		
		if($clientFile->looking_for!=''){
				$print_client_file->setVariable('looking_for',$clientFile->looking_for);
				$print_client_file->showBlock('show_looking_for');
			}
		if($clientFile->budget_buy!=''){
				$print_client_file->setVariable('budget_buy',$clientFile->budget_buy);
				//$print_client_file->setVariable('budget_rent',$clientFile->budget_rent);
				$print_client_file->showBlock('show_budget_buy');
			}
		if($clientFile->budget_rent!=''){
				$print_client_file->setVariable('budget_rent',$clientFile->budget_rent);
				$print_client_file->showBlock('show_budget_rent');
			}
		if($clientFile->renovated!=''){
				$print_client_file->setVariable('renovated',$clientFile->renovated);
				$print_client_file->showBlock('show_renovated');
			}
		if($clientFile->resident!=''){
				$print_client_file->setVariable('resident',$clientFile->resident);
				if($clientFile->date_non_resident!=0){
				$print_client_file->setVariable('date_non_resident',date('Y-m-d',$clientFile->date_non_resident));
				}
				$print_client_file->showBlock('show_resident');
			}
		if($clientFile->id_province!=''){
				$print_client_file->setVariable('province',$clientFile->name_province);
				$print_client_file->showBlock('show_province');
			}
		
		/*if($clientFile->purpose!=''){
				$print_client_file->setVariable('purpose',$clientFile->purpose);
				$print_client_file->showBlock('show_purpose');
			}*/
		if($clientFile->ref_if_any!=''){
				$print_client_file->setVariable('ref_if_any',$clientFile->ref_if_any);
				$print_client_file->showBlock('show_ref_if_any');
			}
		if($clientFile->comment_sale!=''){
				$print_client_file->setVariable('comment_sale',$clientFile->comment_sale);
				$print_client_file->showBlock('show_comment_sale');
			}
		
		//$print_client_file->setVariable('rooftop_fullname','Bona');
		//$print_client_file->setVariable('rooftop_fullname', $_SESSION['login']);
		//$print_client_file->setVariable('login', $_SESSION['login']);
		$user = modelUser::getUser($_SESSION['id_user']);

		//$print_client_file->setVariable('login', $user->login);
		if($user->nom!='' || $user->prenom!=''){
			$print_client_file->setVariable('nom', $user->nom);
			$print_client_file->setVariable('prenom', $user->prenom);
			
		}
		else{$print_client_file->setVariable('login', $user->login);}
		
		$print_client_file->setVariable('client_fullname',$clientFile->first_name.' '.$clientFile->last_name);
		$print_client_file->setVariable('date_creation',date('Y-m-d H:i:s',$clientFile->date_creation));
		
		$print_client_file->showBlock("have_value");
	}
	else{$print_client_file->showBlock("no_value");}
$print_client_file->stop();
$page->setBody($print_client_file);
$page->display();

?>